package com.glsc.ngateway.platform.domain.costallocation;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import java.time.LocalDateTime;
import java.util.List;

/**
 * @author guoj
 * @description: 成本分摊-应用详情总表-ip资产的使用
 * @date 2024/8/7 10:39
 */
@Data
@Entity
@Table(name = "t_ip_info")
@AllArgsConstructor
@NoArgsConstructor
@Builder
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
public class IpInfo {
    @ApiModelProperty(value = "id")
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "l_id", columnDefinition = "int(11) comment '主键ID'")
    private Long id;
    //服务器类型的口径是
    // 若IP从服务器资产的IP1 获取 则为物理机 ，
    // 从虚拟机资产信息获取，则为虚拟机
    // 从 云平台设备获取 则为云平台
    @ApiModelProperty(value = "ip服务器类型-字典项")
    @Column(name = "vc_source_type", columnDefinition = "varchar(10) comment 'ip服务器类型-字典项'")
    private String sourceType;

    //从三个菜单初始化
    @ApiModelProperty(value = "ip")
    @Column(name = "vc_ip", columnDefinition = "varchar(50) comment 'ip'")
    private String ip;

    //服务器资源中 有冷备 在线
    // 云平台虚拟机为null
    @ApiModelProperty(value = "ip状态 取状态字典项")
    @Column(name = "vc_ip_status", columnDefinition = "varchar(50) comment 'ip状态 取状态字典项'")
    private String ipStatus;
    @ApiModelProperty(value = "责任人oa账户")
    @Column(name = "vc_system_user_id", columnDefinition = "varchar(500) comment '责任人 逗号分割 多个'")
    private String systemUserId;
    @ApiModelProperty(value = "责任人姓名")
    @Column(name = "vc_system_user_name", columnDefinition = "varchar(500) comment '责任人 逗号分割 多个'")
    private String systemUserName;

    @ApiModelProperty(value = "更新时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @org.hibernate.annotations.UpdateTimestamp
    @Column(name = "dt_update_time", columnDefinition = "datetime comment '更新时间'")
    protected LocalDateTime updateTime;

    @ApiModelProperty(value = "创建时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @org.hibernate.annotations.UpdateTimestamp
    @Column(name = "dt_create_time", columnDefinition = "datetime comment '创建时间'")
    protected LocalDateTime createTime;

    @ApiModelProperty(value = "虚拟机名称，只有虚拟机管理有该字段")
    @Column(name = "vc_virtual_name", columnDefinition = "varchar(500) comment '虚拟机名称，只有虚拟机管理对应该字段'")
    private String virtualName;

    @ApiModelProperty(value = "应用详情列表")
    @Transient
    private List<IpDetailInfo> ipDetailInfoList;

    //该字段从IT资产外部更新过来 用于应对 ip切换问题
    @ApiModelProperty(value = "唯一标识")
    @Column(name = "vc_unique_key", columnDefinition = "varchar(500) comment '唯一标识'")
    private String uniqueKey;

    @ApiModelProperty(value = "操作人")
    @Column(name = "vc_operator", columnDefinition = "varchar(50) comment '操作人'")
    private String operator;

    @ApiModelProperty(value = "是否填写")
    @Column(name = "vc_has_writed", columnDefinition = "varchar(10) comment '是否填写'")
    private  String hasWrited;
}
